$().ready(function() {
	validateRule();
	
//分页下拉框
    $("#ebatchDiv").on("change", "#ebatchId", function () {
        $.ajax({
            url: '/jzweb/stuSignUp/roomLists',
            data: {ebatchId: $("#ebatchId").val()},
            success: function (r) {
                var list = '<select id="eroomId" name="eroomId" class="form-control">';
                if (r.data.length == 0) {
                    list += '<option value="0">暂无数据</option>';
                } else {
                    list += '<option value="">请选择</option>';
                    for (var p in r.data) {
                        list += '<option value="' + r.data[p].id + '">' + r.data[p].name + '</option>';
                    }
                }
                list += '</select>';
                $("#roomDiv").html(list);
            }
        })
    })
});

$.validator.setDefaults({
	submitHandler : function() {
		save();
	}
});
function save() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/jzweb/exceptionAddtime/saveToRoom",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});
}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			ebatchId : {
				required : true
			},
			addTime : {
				required : true
			},
			remark : {
				required : true
			},
			stuId : {
				required : true
			}
		}
	})
}